home *** CD-ROM | disk | FTP | other *** search
/ Euroscene 2 / Euroscene 2.iso / USEFUL / DeliTracker130 / Developer / Developer.run / Examples / OctaMED.s < prev    next >
Encoding:
Text File  |  1992-09-23  |  52.8 KB  |  2,073 lines

  1.  
  2.     incdir    "Includes:"
  3.     include "misc/DeliPlayer.i"
  4.  
  5. ;
  6. ;
  7.     SECTION Player,Code
  8. ;
  9. ;
  10.  
  11.     PLAYERHEADER PlayerTagArray
  12.  
  13.     dc.b '$VER: OctaMED 3.00 player module V1.5 (18 Jul 92)',0
  14.     even
  15.  
  16. PlayerTagArray
  17.     dc.l    DTP_PlayerVersion,2
  18.     dc.l    DTP_PlayerName,PName
  19.     dc.l    DTP_Creator,CName
  20.     dc.l    DTP_Check2,Chk
  21.     dc.l    DTP_InitPlayer,InitPlay
  22.     dc.l    DTP_EndPlayer,EndPlay
  23.     dc.l    DTP_InitSound,InitSnd
  24.     dc.l    DTP_StartInt,StartSnd
  25.     dc.l    DTP_StopInt,StopSnd
  26.     dc.l    DTP_PrevSong,PrevSub
  27.     dc.l    DTP_NextSong,NextSub
  28.     dc.l    TAG_DONE
  29.  
  30. *-----------------------------------------------------------------------*
  31. ;
  32. ; Player/Creatorname und lokale Daten
  33.  
  34. PName    dc.b 'OctaMED',0
  35. CName    dc.b 'Teijo Kinnunen,',10
  36.     dc.b 'adapted by Delirium',0
  37.     even
  38. med_data    dc.l 0
  39.  
  40. *-----------------------------------------------------------------------*
  41. ;
  42. ; Testet, ob es sich um ein OctaMED-Modul handelt
  43.  
  44. Chk
  45.     move.l    dtg_ChkData(a5),a0
  46.  
  47.     moveq    #-1,d0                ; Modul nicht erkannt (default)
  48.  
  49.     cmpi.l    #"MMD0",(a0)
  50.     beq.s    ChkFlags
  51.  
  52.     cmpi.l    #"MMD1",(a0)
  53.     bne.s    ChkEnd
  54. ChkFlags
  55.     add.l    mmd_songinfo(a0),a0
  56.     btst    #6,msng_flags(a0)        ; >4 voices ?
  57.     beq.s    ChkEnd
  58.  
  59.     moveq    #0,d0                ; Modul erkannt
  60. ChkEnd
  61.     rts
  62.  
  63. *-----------------------------------------------------------------------*
  64. ;
  65. ; Init Player
  66.  
  67. InitPlay
  68.     moveq    #0,d0
  69.     move.l    dtg_GetListData(a5),a0        ; Function
  70.     jsr    (a0)
  71.     move.l    a0,med_data
  72.  
  73.     move.l    a0,-(sp)
  74.     jsr    _RelocModule
  75.     addq.l    #4,sp
  76.  
  77.     clr.w    dtg_SndNum(a5)            ; first Subsong
  78.  
  79.     jsr    _InitPlayer8            ; returncode is already set !
  80.     rts
  81.  
  82. *-----------------------------------------------------------------------*
  83. ;
  84. ; End Player
  85.  
  86. EndPlay
  87.     jsr    _RemPlayer8
  88.     rts
  89.  
  90. *-----------------------------------------------------------------------*
  91. ;
  92. ; Init Sound
  93.  
  94. InitSnd
  95.     move.l    med_data(pc),a0            ; ^Module
  96.     jsr    _InitModule8
  97.     rts
  98.  
  99. *-----------------------------------------------------------------------*
  100. ;
  101. ; Start Play
  102.  
  103. StartSnd
  104.     move.w    dtg_SndNum(a5),_modnum8
  105.     move.l    med_data(pc),a0            ; ^Module
  106.     jsr    _ContModule8
  107.     rts
  108.  
  109. *-----------------------------------------------------------------------*
  110. ;
  111. ; Stop Play
  112.  
  113. StopSnd
  114.     jsr    _StopPlayer8
  115.     rts
  116.  
  117. *-----------------------------------------------------------------------*
  118. ;
  119. ; Previous SubSong
  120.  
  121. PrevSub
  122.     tst.w    dtg_SndNum(a5)
  123.     beq.s    PrevSubEnd
  124.  
  125.     move.l    dtg_StopInt(a5),a0
  126.     jsr    (a0)
  127.     subq.w    #1,dtg_SndNum(a5)        ; Vorheriger Sound
  128.     move.l    dtg_StartInt(a5),a0
  129.     jsr    (a0)
  130. PrevSubEnd
  131.     rts
  132.     
  133. *-----------------------------------------------------------------------*
  134. ;
  135. ; Next SubSong
  136.  
  137. NextSub
  138.     move.l    med_data(pc),a0
  139.     move.w    dtg_SndNum(a5),d0
  140.     addq.w    #1,d0
  141. NextSubLoop
  142.     tst.l    mmd_expdata(a0)
  143.     beq.s    NextSubEnd
  144.     move.l    mmd_expdata(a0),a1
  145.     tst.l    (a1)
  146.     beq.s    NextSubEnd            ;no more modules here!
  147.     move.l    (a1),a0
  148.     subq.w    #1,d0
  149.     bgt.s    NextSubLoop
  150.  
  151.     move.l    dtg_StopInt(a5),a0
  152.     jsr    (a0)
  153.     addq.w    #1,dtg_SndNum(a5)        ; Nächster Sound
  154.     move.l    dtg_StartInt(a5),a0
  155.     jsr    (a0)
  156. NextSubEnd
  157.     rts
  158.  
  159. *-----------------------------------------------------------------------*
  160. ;
  161. ; Relocate Module
  162.  
  163. ;    Function: _RelocModule()
  164. ;    pointer to the module passed in stack
  165.  
  166. ;    SECTION    "text",code
  167.  
  168.     XDEF    _RelocModule
  169.  
  170. reloci    move.l    24(a2),d0
  171.     beq.s    xloci
  172.     movea.l    d0,a0
  173.     moveq   #0,d0
  174.     move.b  787(a1),d0    ;number of samples
  175.     subq.b  #1,d0
  176. relocs:    bsr.s   relocentr
  177.     move.l    -4(a0),d3    ;sample ptr
  178.     beq.s    nosyn
  179.     move.l    d3,a3
  180.     tst.w    4(a3)
  181.     bpl.s    nosyn        ;type >= 0
  182.     move.w    20(a3),d2    ;number of waveforms
  183.     lea    278(a3),a3    ;ptr to wf ptrs
  184.     subq.w    #1,d2
  185. relsyn:    add.l    d3,(a3)+
  186.     dbf    d2,relsyn
  187. nosyn:    dbf     d0,relocs
  188. xloci    rts
  189. norel    addq.l    #4,a0
  190.     rts
  191. relocentr:
  192.     tst.l   (a0)
  193.     beq.s   norel
  194.     add.l   d1,(a0)+
  195.     rts
  196. _RelocModule:
  197.     move.l    4(sp),a0    ;get module pointer from stack
  198.     movem.l    a2-a3/d2-d3,-(sp)
  199.     movea.l a0,a2
  200.     move.l  a2,d1        ;d1 = ptr to start of module
  201.     bsr.s    relocp
  202.     movea.l 8(a2),a1
  203.     bsr.s    reloci
  204. rel_lp    bsr.s    relocb
  205.     move.l    32(a2),d0    ;extension struct
  206.     beq.s    rel_ex
  207.     move.l    d0,a0
  208.     bsr.s    relocentr    ;ptr to next module
  209.     bsr.s    relocentr    ;InstrExt...
  210.     addq.l    #4,a0        ;skip sizes of InstrExt
  211. ; We reloc the pointers of MMD0exp, so anybody who needs them can easily
  212. ; read them.
  213.     bsr.s    relocentr    ;annotxt
  214.     addq.l    #4,a0        ;annolen
  215.     bsr.s    relocentr    ;InstrInfo
  216.     addq.l    #8,a0
  217.     bsr.s    relocentr    ;rgbtable (not useful for most people)
  218.     addq.l    #4,a0        ;skip channelsplit
  219.     bsr.s    relocentr    ;NotationInfo
  220.     bsr.s    relocentr    ;songname
  221.     addq.l    #4,a0        ;skip song name length
  222.     bsr.s    relocentr    ;MIDI dumps
  223.     bsr.s    relocmdd
  224.     move.l    d0,a0
  225.     move.l    (a0),d0
  226.     beq.s    rel_ex
  227.     move.l    d0,a2
  228.     bsr.s    relocp
  229.     movea.l 8(a2),a1
  230.     bra.s    rel_lp
  231. rel_ex    movem.l    (sp)+,d2-d3/a2-a3
  232.     rts
  233.  
  234. relocp    lea    8(a2),a0
  235.     bsr.s    relocentr
  236.     addq.l    #4,a0
  237.     bsr.s    relocentr
  238.     addq.l    #4,a0
  239.     bsr.s    relocentr
  240.     addq.l    #4,a0
  241.     bra.s    relocentr
  242.  
  243. relocb    move.l    16(a2),d0
  244.     beq.s    xlocb
  245.     movea.l    d0,a0
  246.     move.w  504(a1),d0
  247.     subq.b  #1,d0
  248. rebl    bsr.s   relocentr
  249.     dbf     d0,rebl
  250.     cmp.b    #'1',3(a2)    ;test MMD type
  251.     beq.s    relocbi
  252. xlocb    rts
  253.  
  254. relocmdd
  255.     tst.l    -(a0)
  256.     beq.s    xlocmdd
  257.     movea.l    (a0),a0
  258.     move.w    (a0),d0        ;# of msg dumps
  259.     addq.l    #8,a0
  260. mddloop    beq.s    xlocmdd
  261.     bsr    relocentr
  262.     bsr.s    relocdmp
  263.     subq.w    #1,d0
  264.     bra.s    mddloop
  265. xlocmdd    rts
  266.  
  267. relocdmp
  268.     move.l    -4(a0),d3
  269.     beq.s    xlocdmp
  270.     exg.l    a0,d3        ;save
  271.     addq.l    #4,a0
  272.     bsr    relocentr    ;reloc data pointer
  273.     move.l    d3,a0        ;restore
  274. xlocdmp    rts
  275.  
  276. relocbi    move.w    504(a1),d0
  277.     move.l    a0,a3
  278. biloop    subq.w    #1,d0
  279.     bmi.s    xlocdmp
  280.     move.l    -(a3),a0
  281.     addq.l    #4,a0
  282.     bsr    relocentr    ;BlockInfo ptr
  283.     tst.l    -(a0)
  284.     beq.s    biloop
  285.     move.l    (a0),a0
  286.     bsr    relocentr    ;hldata
  287.     bsr    relocentr    ;block name
  288.     bra.s    biloop
  289.  
  290. ;    END
  291.  
  292. *-----------------------------------------------------------------------*
  293. ;
  294. ; Replay Routine
  295.  
  296. ;    pro8player.a
  297. ;    ~~~~~~~~~~~~
  298. ;    The player routine for OctaMED V1.0-3.0 5 - 8 channel songs.
  299. ;    Written by Teijo Kinnunen in 1992.
  300. ;
  301. ; THIS CODE MAY BE FREELY USED AND DISTRIBUTED!
  302.  
  303. ;============================================================================
  304. AUDDEV        EQU 1    ;1 = allocate channels using audio.device
  305. CHECK        EQU 1    ;1 = do range checkings (track, sample in mem etc.)
  306. IFFMOCT        EQU 1    ;1 = play IFF multi-octave samples correctly
  307. HOLD        EQU 1    ;1 = handle hold/decay
  308. PLAYMMD0    EQU 1    ;1 = play old MMD0 modules
  309. ;============================================================================
  310.  
  311. ;the MMD0 structure offsets
  312. mmd_id        EQU    0
  313. mmd_modlen    EQU    4
  314. mmd_songinfo    EQU    8
  315. mmd_blockarr    EQU    16
  316. mmd_smplarr    EQU    24
  317. mmd_expdata    EQU    32
  318. mmd_pstate    EQU    40 ; <0 = play song, 0 = don't play, >0 = play block
  319. mmd_pblock    EQU    42
  320. mmd_pline    EQU    44
  321. mmd_pseqnum    EQU    46
  322. mmd_actplayline    EQU    48
  323. mmd_counter    EQU    50
  324. mmd_songsleft    EQU    51
  325.  
  326. ;the MMD0song structure
  327. ;Instrument data here (504 bytes = 63 * 8)
  328. msng_numblocks    EQU    504
  329. msng_songlen    EQU    506
  330. msng_playseq    EQU    508
  331. msng_deftempo    EQU    764
  332. msng_playtransp    EQU    766
  333. msng_flags    EQU    767
  334. msng_flags2    EQU    768
  335. msng_tempo2    EQU    769
  336. msng_trkvol    EQU    770
  337. msng_mastervol    EQU    786
  338. msng_numsamples    EQU    787
  339.  
  340. ;Instrument data
  341. inst_repeat    EQU    0
  342. inst_replen    EQU    2
  343. inst_midich    EQU    4
  344. inst_midipreset    EQU    5
  345. inst_svol    EQU    6
  346. inst_strans    EQU    7
  347.  
  348. ;Audio hardware offsets
  349. ac_ptr    EQU    $00
  350. ac_len    EQU    $04
  351. ac_per    EQU    $06
  352. ac_vol    EQU    $08
  353. ac_end    EQU    $0C
  354. ac_rest    EQU    $10
  355. ac_mask    EQU    $14
  356. ac_rhw    EQU    $16
  357.  
  358. T03SZ    EQU    98
  359. T415SZ    EQU    18
  360.  
  361.         SECTION    "text",CODE
  362.  
  363. ;**************************************************************************
  364. ;*
  365. ;*        8 CHANNEL PLAY ROUTINE
  366. ;*
  367. ;**************************************************************************
  368.  
  369. ; This code does the magic 8 channel thing (mixing).
  370. MAGIC_8TRK    MACRO
  371.         swap    d6
  372.         swap    d7
  373.         move.b    0(a3,d6.w),d0
  374.         add.b    0(a4,d7.w),d0
  375.         move.b    d0,(a1)+
  376.         swap    d6
  377.         swap    d7
  378.         add.l    d1,d6
  379.         add.l    d2,d7
  380.         ENDM
  381.  
  382. _ChannelO8    lea    trackdata8-DB(a6),a1
  383.         cmp.b    #8,d0
  384.         bge.s    xco8
  385.         lsl.b    #2,d0
  386.         adda.w    d0,a1
  387.         movea.l    (a1),a1
  388.         clr.w    trk_prevper(a1)
  389.         movea.l    trk_audioaddr(a1),a1
  390.         clr.w    ac_per(a1)
  391. xco8        rts
  392.  
  393. _PlayNote8:    ;d7(w) = trk #, d1 = note #, d3(w) = instr # a3 = addr of instr
  394.         movea.l    mmd_smplarr(a2),a0
  395.         add.w    d3,d3            ;d3 = instr.num << 2
  396.         add.w    d3,d3
  397.         move.l    0(a0,d3.w),d5        ;get address of instrument
  398.     IFNE    CHECK
  399.         beq.s    xco8
  400.     ENDC
  401. inmem8:        add.b    msng_playtransp(a4),d1    ;add play transpose
  402.         add.b    inst_strans(a3),d1    ;and instr. transpose
  403.     IFNE    CHECK
  404.         tst.b    inst_midich(a3)
  405.         bne.s    xco8        ;MIDI
  406.     ENDC
  407.         clr.b    trk_vibroffs(a5)    ;clr vibrato offset
  408.         move.l    d5,a0
  409.         subq.b    #1,d1
  410.     IFNE    CHECK
  411.         tst.w    4(a0)
  412.         bmi.s    xco8        ;Synth
  413.     ENDC
  414. tlwtst08:    tst.b    d1
  415.         bpl.s    notenot2low8
  416.         add.b    #12,d1    ;note was too low, octave up
  417.         bra.s    tlwtst08
  418. notenot2low8:    cmp.b    #62,d1
  419.         ble.s    endpttest8
  420.         sub.b    #12,d1    ;note was too high, octave down
  421. endpttest8:
  422.         moveq    #0,d2
  423.         moveq    #0,d3
  424.     IFNE    IFFMOCT
  425.         move.w    4(a0),d0    ;Soitin-struct in a0
  426.         bne.s    iff5or3oct    ;note # in d1 (0 - ...)
  427.     ENDC
  428.         lea    _periodtable+32-DB(a6),a1
  429.         move.b    trk_finetune(a5),d2    ;finetune value
  430.         add.b    d2,d2
  431.         add.b    d2,d2        ;multiply by 4...
  432.         ext.w    d2        ;extend
  433.         movea.l    0(a1,d2.w),a1    ;period table address
  434.         move.l    a1,trk_periodtbl(a5)
  435.         add.b    d1,d1
  436.         move.w    0(a1,d1.w),d5 ;put period to d5
  437.         move.l    a0,d0
  438.         addq.l    #6,d0        ;Skip structure
  439.         move.l    (a0),d1        ;length
  440.         add.l    d0,d1        ;sample end pointer
  441.         move.w    inst_repeat(a3),d2
  442.         move.w    inst_replen(a3),d3
  443.     IFNE    IFFMOCT
  444.         bra    gid_setrept
  445. gid_addtable    dc.b    0,6,12,18,24,30
  446. gid_divtable    dc.b    31,7,3,15,63,127
  447. iff5or3oct:    move.l    d7,-(sp)
  448.         moveq    #0,d7
  449.         move.w    d1,d7
  450.         divu    #12,d7    ;octave #
  451.         move.l    d7,d5
  452.         cmp.w    #6,d7    ;if oct > 5, oct = 5
  453.         blt.s    nohioct
  454.         moveq    #5,d7
  455. nohioct        swap    d5    ;note number in this oct (0-11) is in d5
  456.         move.l    (a0),d1
  457.         cmp.w    #6,d0
  458.         ble.s    nounrecit
  459.         moveq    #6,d0
  460. nounrecit    add.b    gid_addtable-1(pc,d0.w),d7
  461.         move.b    gid_divtable-1(pc,d0.w),d0
  462.         divu    d0,d1    ;get length of the highest octave
  463.         swap    d1
  464.         clr.w    d1
  465.         swap    d1
  466.         move.l    d1,d0        ;d0 and d1 = length of the 1st oct
  467.         move.w    inst_repeat(a3),d2
  468.         move.w    inst_replen(a3),d3
  469.         moveq    #0,d6
  470.         move.b    shiftcnt(pc,d7.w),d6
  471.         lsl.w    d6,d2
  472.         lsl.w    d6,d3
  473.         lsl.w    d6,d1
  474.         move.b    mullencnt(pc,d7.w),d6
  475.         mulu    d6,d0        ;offset of this oct from 1st oct
  476.         add.l    a0,d0        ;add base address to offset
  477.         addq.l    #6,d0        ;skip structure
  478.         add.l    d0,d1
  479.         lea    _periodtable+32-DB(a6),a1
  480.         move.b    trk_finetune(a5),d6
  481.         add.b    d6,d6
  482.         add.b    d6,d6
  483.         ext.w    d6
  484.         movea.l    0(a1,d6.w),a1
  485.         move.l    a1,trk_periodtbl(a5)
  486.         add.b    octstart(pc,d7.w),d5
  487.         add.b    d5,d5
  488.         move.w    0(a1,d5.w),d5
  489.         move.l    (sp)+,d7
  490.         bra.s    gid_setrept
  491. shiftcnt:    dc.b    4,3,2,1,1,0,2,2,1,1,0,0,1,1,0,0,0,0
  492.         dc.b    3,3,2,2,1,0,5,4,3,2,1,0,6,5,4,3,2,1
  493. mullencnt:    dc.b    15,7,3,1,1,0,3,3,1,1,0,0,1,1,0,0,0,0
  494.         dc.b    7,7,3,3,1,0,31,15,7,3,1,0,63,31,15,7,3,1
  495. octstart:    dc.b    12,12,12,12,24,24,0,12,12,24,24,36,0,12,12,24,36,36
  496.         dc.b    0,12,12,24,24,24,12,12,12,12,12,12,12,12,12,12,12,12
  497.     ENDC
  498. gid_setrept    add.l    d2,d2
  499.         add.l    d0,d2        ;rep. start pointer
  500.         cmp.w    #1,d3
  501.         bhi.s    gid_noreplen2
  502.         moveq    #0,d3        ;no repeat
  503.         bra.s    gid_cont
  504. gid_noreplen2    add.l    d3,d3
  505.         add.l    d2,d3        ;rep. end pointer
  506.  
  507. gid_cont    movea.l    trk_audioaddr(a5),a1 ;base of this channel's regs
  508.         move.l    d0,(a1)        ;put it in ac_ptr
  509.         cmp.l    d0,d3
  510.         bhi.s    repeat8
  511.  
  512.         tst.b    trk_split(a5)
  513.         beq.s    pn8_nosplit0
  514.         clr.l    ac_rest(a1)
  515.         subq.l    #1,d1
  516.         move.l    d1,ac_end(a1)
  517.         bra.s    retsn18
  518.  
  519. pn8_nosplit0    sub.l    d0,d1
  520.         lsr.l    #1,d1
  521.         move.w    d1,ac_len(a1)
  522.         move.l    #_chipzero,ac_rest(a1)
  523.         move.w    #1,ac_end(a1)
  524.         bra.s    retsn18
  525.  
  526. repeat8:    tst.b    trk_split(a5)
  527.         bne.s    pn8_split1
  528.         move.l    d3,d1
  529.         sub.l    d0,d1
  530.         lsr.l    #1,d1
  531.         move.w    d1,ac_len(a1)
  532.         move.l    d2,ac_rest(a1)    ;remember rep. start
  533.         sub.l    d2,d3
  534.         lsr.l    #1,d3
  535.         move.w    d3,ac_end(a1)    ;remember rep. length
  536.         bra.s    retsn18
  537.  
  538. pn8_split1    move.l    d2,ac_rest(a1)
  539.         move.l    d3,ac_end(a1)
  540. retsn18:    move.w    d5,ac_per(a1)    ;getinsdata puts period to d5
  541.         move.w    d5,trk_prevper(a5)
  542. retsn28:    rts
  543.  
  544. _IntHandler8:    movem.l    d2-d7/a2-a5,-(sp)
  545.         lea    DB,a6
  546.         lea    trksplit-DB(a6),a2
  547.         move.w    currchsize2-DB(a6),d4
  548. ; ================ 8 channel handling (buffer swap) ======
  549.         move.w    #800,d0
  550.         not.b    whichbuff-DB(a6)    ;swap buffer
  551.         bne.s    usebuff1
  552.         tst.b    (a2)+
  553.         beq.s    tnspl0
  554.         move.l    a1,$a0(a0)
  555.         move.w    d4,$a4(a0)
  556. tnspl0        lea    800(a1),a5
  557.         tst.b    (a2)+
  558.         beq.s    tnspl1
  559.         move.l    a5,$b0(a0)
  560.         move.w    d4,$b4(a0)
  561. tnspl1        adda.w    d0,a5
  562.         tst.b    (a2)+
  563.         beq.s    tnspl2
  564.         move.l    a5,$c0(a0)
  565.         move.w    d4,$c4(a0)
  566. tnspl2        adda.w    d0,a5
  567.         tst.b    (a2)
  568.         beq.s    buffset
  569.         move.l    a5,$d0(a0)
  570.         move.w    d4,$d4(a0)
  571.         bra.s    buffset
  572. usebuff1    lea    400(a1),a1
  573.         tst.b    (a2)+
  574.         beq.s    tnspl0b
  575.         move.l    a1,$a0(a0)
  576.         move.w    d4,$a4(a0)
  577. tnspl0b        lea    800(a1),a5
  578.         tst.b    (a2)+
  579.         beq.s    tnspl1b
  580.         move.l    a5,$b0(a0)
  581.         move.w    d4,$b4(a0)
  582. tnspl1b        adda.w    d0,a5
  583.         tst.b    (a2)+
  584.         beq.s    tnspl2b
  585.         move.l    a5,$c0(a0)
  586.         move.w    d4,$c4(a0)
  587. tnspl2b        tst.b    (a2)
  588.         beq.s    buffset
  589.         adda.w    d0,a5
  590.         move.l    a5,$d0(a0)
  591.         move.w    d4,$d4(a0)
  592. buffset        move.w    #1<<7,$9c(a0)
  593.         move.l    #3719168,d3    ;227 * 16384
  594. ; ============== fill buffers ============
  595. startfillb    moveq    #0,d4        ;mask for DMA
  596.         lea    track0hw-DB(a6),a2
  597.         tst.b    trksplit-DB(a6)
  598.         bne.s    tspl0c
  599.         bsr.w    pushregs
  600.         bra.s    tnspl0c
  601. tspl0c        bsr.s    fillbuf
  602.         movea.l    a5,a1
  603. tnspl0c        lea    track1hw-DB(a6),a2
  604.         tst.b    trksplit+1-DB(a6)
  605.         bne.s    tspl1c
  606.         bsr.w    pushregs
  607.         bra.s    tnspl1c
  608. tspl1c        bsr.s    fillbuf
  609.         movea.l    a5,a1
  610. tnspl1c        lea    track2hw-DB(a6),a2
  611.         tst.b    trksplit+2-DB(a6)
  612.         bne.s    tspl2c
  613.         bsr.w    pushregs
  614.         bra.s    tnspl2c
  615. tspl2c        bsr.s    fillbuf
  616.         movea.l    a5,a1
  617. tnspl2c        lea    track3hw-DB(a6),a2
  618.         tst.b    trksplit+3-DB(a6)
  619.         bne.s    tspl3c
  620.         bsr.w    pushregs
  621.         bra.w    do_play8
  622. tspl3c        bsr.s    fillbuf
  623.         bra.w    do_play8
  624. ; =========================================================
  625. ;calculate channel A period
  626. fillbuf:    move.l    d3,d7
  627.         move.w    ac_per(a2),d6
  628.         beq.s    setpzero0
  629.         move.l    d7,d2
  630.         divu     d6,d2
  631.         moveq    #0,d1
  632.         move.w    d2,d1
  633.         add.l    d1,d1
  634.         add.l    d1,d1
  635. ;get channel A addresses
  636.         move.l    ac_end(a2),a5
  637.         move.l    (a2),d0
  638.         beq.s    setpzero0
  639. chA_dfnd    move.l    d0,a3    ;a3 = start address, a5 = end address
  640. ;calc bytes before end
  641.         mulu    currchsize-DB(a6),d2
  642.         clr.w    d2
  643.         swap    d2
  644. ; d2 = # of bytes/fill
  645.         add.l    a3,d2    ;d2 = end position after this fill
  646.         sub.l    a5,d2    ;subtract sample end
  647.         bmi.s    norestart0
  648.         move.l    ac_rest(a2),d0
  649.         beq.s    rst0end
  650.         move.l    d0,(a2)
  651.         move.l    d0,a3
  652.         bra.s    norestart0
  653. rst0end        clr.l    (a2)
  654. setpzero0    lea    zerodata-DB(a6),a3
  655.         moveq    #0,d1
  656. norestart0
  657. ;channel B period
  658.         move.w    SIZE4TRKHW+ac_per(a2),d6
  659.         beq.s    setpzero0b
  660.         divu    d6,d7
  661.         moveq    #0,d2
  662.         move.w    d7,d2
  663.         add.l    d2,d2
  664.         add.l    d2,d2
  665. ;channel B addresses
  666.         move.l    SIZE4TRKHW+ac_end(a2),a5
  667.         move.l    SIZE4TRKHW(a2),d0
  668.         beq.s    setpzero0b
  669.         move.l    d0,a4
  670.         mulu    currchsize-DB(a6),d7
  671.         clr.w    d7
  672.         swap    d7
  673.         add.l    a4,d7
  674.         sub.l    a5,d7
  675.         bmi.s    norestart0b
  676.         move.l    SIZE4TRKHW+ac_rest(a2),d0
  677.         beq.s    rst0endb
  678.         move.l    d0,SIZE4TRKHW(a2)
  679.         move.l    d0,a4
  680.         bra.s    norestart0b
  681. rst0endb    clr.l    SIZE4TRKHW(a2)
  682. setpzero0b    lea    zerodata-DB(a6),a4
  683.         moveq    #0,d2
  684. norestart0b    moveq    #0,d6
  685.         moveq    #0,d7
  686.         move.w    currchszcnt-DB(a6),d5
  687.         lea    800(a1),a5    ;get addr. of next buffer
  688. do8trkmagic
  689.         MAGIC_8TRK    ;20 times..
  690.         MAGIC_8TRK
  691.         MAGIC_8TRK
  692.         MAGIC_8TRK
  693.         MAGIC_8TRK
  694.         MAGIC_8TRK
  695.         MAGIC_8TRK
  696.         MAGIC_8TRK
  697.         MAGIC_8TRK
  698.         MAGIC_8TRK
  699.         MAGIC_8TRK
  700.         MAGIC_8TRK
  701.         MAGIC_8TRK
  702.         MAGIC_8TRK
  703.         MAGIC_8TRK
  704.         MAGIC_8TRK
  705.         MAGIC_8TRK
  706.         MAGIC_8TRK
  707.         MAGIC_8TRK
  708.         MAGIC_8TRK
  709.  
  710.         dbf    d5,do8trkmagic    ;do until cnt zero
  711. end8trkmagic    clr.w    d6
  712.         clr.w    d7
  713.         swap    d6
  714.         swap    d7
  715.         add.l    d6,(a2)
  716.         add.l    d7,SIZE4TRKHW(a2)
  717.         rts
  718.  
  719. _Wait1line:    move.l    d0,-(sp)
  720.         moveq    #$79,d0
  721. wl0:        move.b    $dff007,d1
  722. wl1:        cmp.b    $dff007,d1
  723.         beq.s    wl1
  724.         dbf    d0,wl0
  725.         move.l    (sp)+,d0
  726.         rts
  727. ; ========== this channel is not splitted
  728. pushregs    move.l    ac_rhw(a2),a3        ;address of real hardware
  729.         move.w    ac_per(a2),ac_per(a3)    ;push new period
  730.         move.l    (a2),d0    ;ac_ptr
  731.         beq.s    pregs_nonewp
  732.         move.w    ac_mask(a2),d1
  733.         move.w    d1,$96(a0)    ;stop DMA of curr. channel
  734.         or.w    d1,d4
  735.         clr.l    (a2)+
  736.         move.l    d0,(a3)+    ;to real ac_ptr
  737.         move.w    (a2),(a3)    ;push ac_len
  738. pregs_nonewp    lea    400(a1),a1    ;next buffer
  739.         rts
  740. ; ========== should we start DMA of non-splitted channels?
  741. do_play8    tst.w    d4
  742.         beq.s    do_play8_b    ;no.
  743.         bsr.s    _Wait1line
  744.         bset    #15,d4
  745.         move.w    d4,$96(a0)
  746.         bsr.s    _Wait1line
  747.         lsr.b    #1,d4
  748.         bcc.s    plr_nos8dma0
  749.         move.l    track0hw+ac_rest-DB(a6),$a0(a0)
  750.         move.w    track0hw+ac_end-DB(a6),$a4(a0)
  751. plr_nos8dma0    lsr.b    #1,d4
  752.         bcc.s    plr_nos8dma1
  753.         move.l    track1hw+ac_rest-DB(a6),$b0(a0)
  754.         move.w    track1hw+ac_end-DB(a6),$b4(a0)
  755. plr_nos8dma1    lsr.b    #1,d4
  756.         bcc.s    plr_nos8dma2
  757.         move.l    track2hw+ac_rest-DB(a6),$c0(a0)
  758.         move.w    track2hw+ac_end-DB(a6),$c4(a0)
  759. plr_nos8dma2    lsr.b    #1,d4
  760.         bcc.s    do_play8_b
  761.         move.l    track3hw+ac_rest-DB(a6),$d0(a0)
  762.         move.w    track3hw+ac_end-DB(a6),$d4(a0)
  763. ; ========== player starts here...
  764. do_play8_b    movea.l    _module8-DB(a6),a2
  765.         move.l    a2,d0
  766.         beq.w    plr_exit8
  767.         move.l    mmd_songinfo(a2),a4
  768.         moveq    #0,d3
  769.         lea    mmd_counter(a2),a0
  770.         move.b    (a0),d3
  771.         addq.b    #1,d3
  772.         cmp.b    msng_tempo2(a4),d3
  773.         bge.s    plr_pnewnote8    ;play new note
  774.         move.b    d3,(a0)
  775.         bra.w    nonewnote8    ;do just fx
  776. ; --- new note!! first get address of current block
  777. plr_pnewnote8:    clr.b    (a0)
  778.         tst.w    blkdelay-DB(a6)
  779.         beq.s    plr_noblkdelay8
  780.         subq.w    #1,blkdelay-DB(a6)
  781.         bne.w    nonewnote8
  782. plr_noblkdelay8    move.w    mmd_pblock(a2),d0
  783.         movea.l    mmd_blockarr(a2),a0
  784.         add.w    d0,d0
  785.         add.w    d0,d0
  786.         movea.l    0(a0,d0.w),a1    ;block...
  787.         move.w    mmd_pline(a2),d0
  788.     IFNE    PLAYMMD0
  789.         cmp.b    #'1',3(a2)    ;check ID type
  790.         beq.s    plr_mmd1_0
  791.         move.w    d0,d1
  792.         add.w    d0,d0
  793.         add.w    d1,d0        ;d0 = d0 * 3
  794.         clr.l    numtracks-DB(a6)
  795.         move.b    (a1)+,numtracks+1-DB(a6)
  796.         move.b    (a1),numlines+1-DB(a6)
  797.         mulu    numtracks-DB(a6),d0
  798.         pea    1(a1,d0.w)
  799.         bra.s    plr_begloop
  800. plr_mmd1_0
  801.     ENDC
  802.         add.w    d0,d0
  803.         add.w    d0,d0        ;d0 = d0 * 4
  804.         mulu    (a1),d0        ;numtracks * d0
  805.         pea    8(a1,d0.l)    ;address of the current note
  806.         move.w    (a1)+,numtracks-DB(a6)
  807.         move.w    (a1),numlines-DB(a6)
  808. plr_begloop    moveq    #0,d7        ;number of track
  809.         moveq    #0,d4
  810.         pea    trackdata8-DB(a6)
  811. plr_loop08    moveq    #0,d5
  812.         cmp.w    #8,d7
  813.         bge.w    plr_endloop08
  814.         move.l    (sp),a1
  815.         movea.l    (a1)+,a5    ;get address of this track's struct
  816.         move.l    a1,(sp)
  817. ; ---------------- get the note numbers
  818.         moveq    #0,d3
  819.         move.l    4(sp),a1
  820.     IFNE    PLAYMMD0
  821.         cmp.b    #'1',3(a2)
  822.         beq.s    plr_mmd1_1
  823.         move.b    (a1)+,d5
  824.         move.b    (a1)+,d6
  825.         move.b    (a1)+,trk_cmdqual(a5)
  826.         move.b    d6,d3
  827.         and.w    #$0F,d6
  828.         lsr.b    #4,d3
  829.         bclr    #7,d5
  830.         beq.s    plr_bseti4
  831.         bset    #4,d3
  832. plr_bseti4    bclr    #6,d5
  833.         beq.s    plr_bseti5
  834.         bset    #5,d3
  835. plr_bseti5    bra.s    plr_nngok
  836. plr_mmd1_1
  837.     ENDC
  838.         move.b    (a1)+,d5    ;get the number of this note
  839.         bpl.s    plr_nothinote
  840.         moveq    #0,d5
  841. plr_nothinote    move.b    (a1)+,d3    ;instrument number
  842.         move.b    (a1)+,d6    ;cmd number
  843.         and.w    #$1F,d6        ;recognize only cmds 00 - 1F
  844.         move.b    (a1)+,trk_cmdqual(a5)    ;databyte (qualifier)
  845. plr_nngok    move.l    a1,4(sp)
  846. ; ---------------- check if there's an instrument number
  847.         and.w    #$3F,d3
  848.         beq.s    noinstnum8
  849. ; ---------------- finally, save the number
  850.         subq.b    #1,d3
  851.         move.b    d3,trk_previnstr(a5) ;remember instr. number!
  852.     IFNE    HOLD
  853.         lea    holdvals-DB(a6),a0
  854.         adda.w    d3,a0
  855.         move.b    (a0),trk_inithold(a5)
  856.         move.b    63(a0),trk_finetune(a5)
  857.     ENDC
  858.         asl.w    #3,d3
  859.         lea    0(a4,d3.w),a3    ;a3 contains now address of it
  860.         move.l    a3,trk_previnstra(a5)
  861.         moveq    #0,d0
  862. ; ---------------- set volume to 64
  863.         movea.l    trk_audioaddr(a5),a0
  864.         movea.l    ac_vol(a0),a0    ;ptr to volume hardware register
  865.         moveq    #64,d0
  866.         move.b    d0,(a0)
  867.         move.b    d0,trk_prevvol(a5)
  868. ; ---------------- remember transpose
  869.         move.b    inst_strans(a3),trk_stransp(a5)
  870.         clr.w    trk_soffset(a5)        ;sample offset
  871. ; ---------------- check the commands
  872. noinstnum8    move.b    d6,trk_cmd(a5)    ;save the effect number
  873.         beq.w    fx8    ;no effect
  874.         move.b    trk_cmdqual(a5),d4    ;get qualifier...
  875.         add.b    d6,d6    ;* 2
  876.         move.w    f_table8(pc,d6.w),d0
  877.         jmp    fst8(pc,d0.w)
  878. f_table8    dc.w    fx8-fst8,fx8-fst8,fx8-fst8,f_038-fst8,fx8-fst8,fx8-fst8,fx8-fst8,fx8-fst8
  879.         dc.w    f_088-fst8,f_098-fst8,fx8-fst8,f_0b8-fst8,f_0c8-fst8,fx8-fst8,fx8-fst8,f_0f8-fst8
  880.         dc.w    fx8-fst8,fx8-fst8,fx8-fst8,fx8-fst8,fx8-fst8,f_158-fst8,f_168-fst8,fx8-fst8
  881.         dc.w    fx8-fst8,f_198-fst8,fx8-fst8,fx8-fst8,fx8-fst8,f_1d8-fst8,fx8-fst8,f_1f8-fst8
  882. fst8
  883. ; ---------------- tempo (F)
  884. f_0f8        tst.b    d4        ;test effect qual..
  885.         beq.s    fx0fchgblck8    ;if effect qualifier (last 2 #'s)..
  886.         cmp.b    #$f0,d4        ;..is zero, go to next block
  887.         bhi.s    fx0fspecial8
  888.         moveq    #0,d0
  889.         move.b    d4,d0
  890.         bsr.w    _SetTempo
  891.         bra.w    fx8
  892. ; ---------------- no, it was FFx
  893. fx0fspecial8    cmp.b    #$f2,d4
  894.         bne.s    isfxfe8
  895. ; ---------------- it was FF2, nothing to do now
  896. f_1f8        move.b    d5,(a5)    ; save the note number
  897.         moveq    #0,d5    ; clear the number for awhile
  898.     IFNE    HOLD
  899.         move.b    trk_inithold(a5),trk_noteoffcnt(a5) ;initialize hold
  900.         bne.w    plr_endloop08    
  901.         st    trk_noteoffcnt(a5)
  902.     ENDC
  903.         bra.w    plr_endloop08
  904. isfxfe8        cmp.b    #$fe,d4
  905.         bne.s    notcmdfe8
  906. ; ---------------- it was FFE, stop playing
  907.         clr.w    mmd_pstate(a2)
  908.         bra.w    fx8
  909. notcmdfe8    cmp.b    #$fd,d4 ;change period
  910.         bne.s    isfxff8
  911. ; ---------------- FFD, change the period, don't replay the note
  912.         cmp.w    #8,d7
  913.         bge.w    fx8
  914.         movea.l    trk_periodtbl(a5),a0    ;period table
  915.         subq.b    #1,d5
  916.         bmi.w    plr_endloop08    ;under zero, do nothing
  917.         add.b    d5,d5
  918.         move.w    0(a0,d5.w),trk_prevper(a5) ;get & push the period
  919.         moveq    #0,d5        ;don't retrigger note
  920.         bra.w    fx8    ;done!!
  921. isfxff8        cmp.b    #$ff,d4        ;note off??
  922.         bne.w    fx8
  923.         move.w    d7,d0
  924.         bsr.w    _ChannelO8
  925.         bra.w    fx8
  926. ; ---------------- F00
  927. fx0fchgblck8    move.b    #1,nextblock-DB(a6)
  928.         bra.w    fx8
  929. ; ---------------- change volume
  930. f_0c8        btst    #4,msng_flags(a4)    ;look at flags
  931.         bne.s    volhex8
  932.         move.b    d4,d1        ;get again
  933.         lsr.b    #4,d4        ;get number from left
  934.         mulu    #10,d4        ;number of tens
  935.         and.b    #$0f,d1        ;this time don't get tens
  936.         add.b    d1,d4        ;add them
  937. volhex8        cmp.b    #64,d4
  938.         bhi.s    go_nocmd8
  939.         movea.l    trk_audioaddr(a5),a0
  940.         movea.l    ac_vol(a0),a0
  941.         move.b    d4,(a0)
  942. go_nocmd8    bra.w    fx8
  943. ; ---------------- tempo2 change??
  944. f_098
  945.     IFNE    CHECK
  946.         and.b    #$1F,d4
  947.         bne.s    fx9chk8
  948.         moveq    #$20,d4
  949.     ENDC
  950. fx9chk8        move.b    d4,msng_tempo2(a4)
  951.         bra    fx8
  952. ; ---------------- finetune
  953. f_158
  954.     IFNE    CHECK
  955.         cmp.b    #7,d4
  956.         bgt    fx8
  957.         cmp.b    #-8,d4
  958.         blt    fx8
  959.     ENDC
  960.         move.b    d4,trk_finetune(a5)
  961.         bra    fx8
  962. ; ---------------- repeat loop
  963. f_168        tst.b    d4
  964.         bne.s    plr_dorpt8
  965.         move.w    mmd_pline(a2),rptline-DB(a6)
  966.         bra    fx8
  967. plr_dorpt8    tst.w    rptcounter-DB(a6)
  968.         beq.s    plr_newrpt8
  969.         subq.w    #1,rptcounter-DB(a6)
  970.         beq.s    fx8
  971.         bra.s    plr_setrptline8
  972. plr_newrpt8    move.b    d4,rptcounter+1-DB(a6)
  973. plr_setrptline8    move.w    rptline-DB(a6),d0
  974.         addq.w    #1,d0
  975.         move.w    d0,nextblockline-DB(a6)
  976.         bra.s    fx8
  977. ; ---------------- note off time set??
  978. f_088
  979.     IFNE    HOLD
  980.         move.b    d4,d0
  981.         and.b    #$0f,d4
  982.         move.b    d4,trk_inithold(a5)    ;right = hold
  983.     ENDC
  984.         bra.s    fx8
  985. ; ---------------- sample begin offset
  986. f_198        tst.b    d4
  987.         beq.s    fx8
  988.         lsl.w    #8,d4
  989.         move.w    d4,trk_soffset(a5)
  990.         bra.s    fx8
  991. ; ---------------- cmd Bxx, "position jump"
  992. f_0b8    
  993.     IFNE    CHECK
  994.         cmp.w    msng_songlen(a4),d4    ;test the song length
  995.         bhi.s    fx8
  996.     ENDC
  997.         move.w    d4,mmd_pseqnum(a2)
  998.         st    nextblock-DB(a6)
  999.         bra.s    fx8
  1000. ; ---------------- cmd 1Dxx, jump to next seq, line # specified
  1001. f_1d8        move.w    #$1ff,nextblock-DB(a6)
  1002.         addq.w    #1,d4
  1003.         move.w    d4,nextblockline-DB(a6)
  1004.         bra.s    fx8
  1005. ; ---------------- try portamento (3)
  1006. f_038        subq.b    #1,d5
  1007.         bmi.s    plr_setfx3spd8
  1008. plr_fx3note8    movea.l    trk_periodtbl(a5),a0
  1009.         add.b    msng_playtransp(a4),d5    ;play transpose
  1010.         add.b    trk_stransp(a5),d5 ;and instrument transpose
  1011.         bmi.s    plr_endloop08    ;again.. too low
  1012.         add.w    d5,d5
  1013.         move.w    0(a0,d5.w),trk_porttrgper(a5) ;period of this note is the target
  1014. plr_setfx3spd8    tst.b    d4        ;qual?
  1015.         beq.s    plr_endloop08    ;0 -> do nothing
  1016.         move.b    d4,trk_prevportspd(a5)    ;remember size
  1017.         bra.s    plr_endloop08
  1018. ; ---------------- everything is checked now: play or not to play??
  1019. fx8        tst.b    d5    ;Now we'll check if we have to play a note
  1020.         beq.s    plr_endloop08    ;no.
  1021. ; ---------------- we decided to play
  1022.         move.b    d5,(a5)
  1023.         move.w    d5,d1
  1024.         moveq    #0,d3
  1025.         move.b    trk_previnstr(a5),d3    ;instr #
  1026.         movea.l    trk_previnstra(a5),a3    ;instr data address
  1027.     IFNE    HOLD
  1028.         move.b    trk_inithold(a5),trk_noteoffcnt(a5)
  1029.         bne.s    plr_nohold8
  1030.         st    trk_noteoffcnt(a5)
  1031.     ENDC
  1032. ; ---------------- and finally:
  1033. plr_nohold8    bsr    _PlayNote8
  1034. ; ---------------- end of loop: handle next track, or quit
  1035. plr_endloop08    addq.b    #1,d7
  1036.         cmp.w    numtracks-DB(a6),d7
  1037.         blt.w    plr_loop08
  1038.         addq.l    #8,sp        ;trackdataptrs
  1039.         lea    trackdata8-DB(a6),a5
  1040. ; and advance song pointers
  1041.         lea    nextblock-DB(a6),a3
  1042.         move.w    nextblockline-DB(a6),d1
  1043.         beq.s    plr_advlinenum
  1044.         clr.w    nextblockline-DB(a6)
  1045.         subq.w    #1,d1
  1046.         bra.s    plr_linenumset
  1047. plr_advlinenum    move.w    mmd_pline(a2),d1    ;get current line #
  1048.         addq.w    #1,d1            ;advance line number
  1049. plr_linenumset    cmp.w    numlines-DB(a6),d1     ;advance block?
  1050.         bhi.s    plr_chgblock        ;yes.
  1051.         tst.b    (a3)            ;command F00/1Dxx?
  1052.         beq.s    plr_nochgblock        ;no, don't change block
  1053. plr_chgblock    tst.b    nxtnoclrln-DB(a6)
  1054.         bne.s    plr_noclrln
  1055.         moveq    #0,d1            ;clear line number
  1056. plr_noclrln    tst.w    mmd_pstate(a2)        ;play block or play song
  1057.         bpl.s    plr_nonewseq        ;play block only...
  1058.         move.w    mmd_pseqnum(a2),d0    ;get play sequence number
  1059.         tst.b    (a3)
  1060.         bmi.s    plr_noadvseq        ;Bxx sets nextblock to -1
  1061.         addq.w    #1,d0            ;advance sequence number
  1062. plr_noadvseq    cmp.w    msng_songlen(a4),d0    ;is this the highest seq number??
  1063.         blt.s    plr_notagain        ;no.
  1064.         moveq    #0,d0            ;yes: restart song
  1065. plr_notagain    move.b    d0,mmd_pseqnum+1(a2)    ;remember new playseq-#
  1066.         lea    msng_playseq(a4),a0    ;offset of sequence table
  1067.         move.b    0(a0,d0.w),d0        ;get number of the block
  1068.     IFNE    CHECK
  1069.         cmp.w    msng_numblocks(a4),d0    ;beyond last block??
  1070.         blt.s    plr_nolstblk        ;no..
  1071.         moveq    #0,d0            ;play block 0
  1072.     ENDC
  1073. plr_nolstblk    move.b    d0,mmd_pblock+1(a2)    ;store block number
  1074. plr_nonewseq    clr.w    (a3)             ;clear this if F00 set it
  1075. plr_nochgblock    move.w    d1,mmd_pline(a2)    ;set new line number
  1076.  
  1077.     IFNE    HOLD
  1078.         lea    trackdata8-DB(a6),a5
  1079.         movea.l    mmd_blockarr(a2),a0
  1080.         move.w    mmd_pblock(a2),d0
  1081.         add.w    d0,d0
  1082.         add.w    d0,d0
  1083.         movea.l    0(a0,d0.w),a1    ;block...
  1084.         move.w    mmd_pline(a2),d0
  1085.         move.b    msng_tempo2(a4),d3    ;interrupts/note
  1086.     IFNE    PLAYMMD0
  1087.         cmp.b    #'1',3(a2)
  1088.         beq.s    plr_mmd1_2
  1089.         move.b    (a1),d7            ;# of tracks
  1090.         move.w    d0,d1
  1091.         add.w    d0,d0    ;d0 * 2
  1092.         add.w    d1,d0    ;+ d0 = d0 * 3
  1093.         mulu    d7,d0
  1094.         lea    2(a1,d0.w),a3
  1095.         subq.b    #1,d7
  1096. plr_chkholdb    movea.l    (a5)+,a1        ;track data
  1097.         tst.b    trk_noteoffcnt(a1)    ;hold??
  1098.         bmi.s    plr_holdendb        ;no.
  1099.         move.b    (a3),d1            ;get the 1st byte..
  1100.         bne.s    plr_hold1b
  1101.         move.b    1(a3),d1
  1102.         and.b    #$f0,d1
  1103.         beq.s    plr_holdendb        ;don't hold
  1104.         bra.s    plr_hold2b
  1105. plr_hold1b    and.b    #$3f,d1            ;note??
  1106.         beq.s    plr_hold2b        ;no, cont hold..
  1107.         move.b    1(a3),d1
  1108.         and.b    #$0f,d1            ;get cmd
  1109.         subq.b    #3,d1            ;is there command 3 (slide)
  1110.         bne.s    plr_holdendb        ;no -> end holding
  1111. plr_hold2b    add.b    d3,trk_noteoffcnt(a1)    ;continue holding...
  1112. plr_holdendb    addq.l    #3,a3        ;next note
  1113.         dbf    d7,plr_chkholdb
  1114.         bra.s    nonewnote8
  1115. plr_mmd1_2
  1116.     ENDC
  1117.         move.w    (a1),d7        ;# of tracks
  1118.         add.w    d0,d0
  1119.         add.w    d0,d0    ;d0 = d0 * 4
  1120.         mulu    d7,d0
  1121.         lea    8(a1,d0.l),a3
  1122.         subq.b    #1,d7
  1123. plr_chkhold    movea.l    (a5)+,a1        ;track data
  1124.         tst.b    trk_noteoffcnt(a1)    ;hold??
  1125.         bmi.s    plr_holdend        ;no.
  1126.         move.b    (a3),d1            ;get the 1st byte..
  1127.         bne.s    plr_hold1
  1128.         move.b    1(a3),d0
  1129.         and.b    #$3F,d0
  1130.         beq.s    plr_holdend        ;don't hold
  1131.         bra.s    plr_hold2
  1132. plr_hold1    and.b    #$7f,d1            ;note??
  1133.         beq.s    plr_hold2        ;no, cont hold..
  1134.         move.b    2(a3),d1
  1135.         subq.b    #3,d1            ;is there command 3 (slide)
  1136.         bne.s    plr_holdend        ;no -> end holding
  1137. plr_hold2    add.b    d3,trk_noteoffcnt(a1)    ;continue holding...
  1138. plr_holdend    addq.l    #4,a3        ;next note
  1139.         dbf    d7,plr_chkhold
  1140.     ENDC    
  1141. nonewnote8    moveq    #0,d3
  1142.         move.b    mmd_counter(a2),d3
  1143. plr_fxtime    lea    trackdata8-DB(a6),a3
  1144.         moveq    #0,d7    ;clear track count
  1145. plr_loop1:    movea.l    (a3)+,a5
  1146.         cmp.w    #8,d7
  1147.         bge.w    endl
  1148.         moveq    #0,d4
  1149.         moveq    #0,d5
  1150.         moveq    #0,d6
  1151.         move.b    trk_cmd(a5),d6    ;get the fx number
  1152.         move.b    trk_cmdqual(a5),d4    ;and the last 2 #'s
  1153.     IFNE    HOLD
  1154.         tst.b    trk_noteoffcnt(a5)
  1155.         bmi.s    plr_nofade
  1156.         subq.b    #1,trk_noteoffcnt(a5)
  1157.         bpl.s    plr_nofade
  1158.         move.w    d7,d0
  1159.         bsr.w    _ChannelO8
  1160. plr_nofade
  1161.     ENDC
  1162.         add.b    d6,d6    ;* 2
  1163.         move.w    fx_table(pc,d6.w),d0
  1164.         jmp    fxs(pc,d0.w)
  1165. fx_table    dc.w    fx_00-fxs,fx_01-fxs,fx_02-fxs,fx_03-fxs,fx_04-fxs
  1166.         dc.w    fx_05-fxs,fx_06-fxs,fx_07-fxs,fx_xx-fxs,fx_xx-fxs
  1167.         dc.w    fx_0a-fxs,fx_xx-fxs,endl-fxs,fx_0d-fxs,fx_xx-fxs
  1168.         dc.w    fx_0f-fxs
  1169.         dc.w    fx_xx-fxs,fx_11-fxs,fx_12-fxs,fx_13-fxs,fx_14-fxs
  1170.         dc.w    fx_xx-fxs,fx_xx-fxs,fx_xx-fxs,fx_18-fxs,fx_xx-fxs
  1171.         dc.w    fx_1a-fxs,fx_1b-fxs,fx_xx-fxs,fx_xx-fxs,fx_1e-fxs
  1172.         dc.w    fx_1f-fxs
  1173. fxs:
  1174. ;    **************************************** Effect 01 ******
  1175. fx_01:        tst.b    d3
  1176.         bne.s    fx_01nocnt0
  1177.         btst    #5,msng_flags(a4)    ;FLAG_STSLIDE??
  1178.         bne    endl
  1179. fx_01nocnt0    sub.w    d4,trk_prevper(a5)
  1180.         move.w    trk_prevper(a5),d5
  1181.         cmp.w    #113,d5
  1182.         bge    plr_newper
  1183.         move.w    #113,d5
  1184.         move.w    d5,trk_prevper(a5)
  1185.         bra    plr_newper
  1186. ;    **************************************** Effect 11 ******
  1187. fx_11        tst.b    d3
  1188.         bne    fx_xx
  1189.         sub.w    d4,trk_prevper(a5)
  1190.         move.w    trk_prevper(a5),d5
  1191.         bra    plr_newper
  1192. ;    **************************************** Effect 02 ******
  1193. fx_02:        tst.b    d3
  1194.         bne.s    fx_02nocnt0
  1195.         btst    #5,msng_flags(a4)
  1196.         bne    endl
  1197. fx_02nocnt0    add.w    d4,trk_prevper(a5)
  1198.         move.w    trk_prevper(a5),d5
  1199.         bra.w    plr_newper
  1200. ;    **************************************** Effect 12 ******
  1201. fx_12        tst.b    d3
  1202.         bne    fx_xx
  1203.         add.w    d4,trk_prevper(a5)
  1204.         move.w    trk_prevper(a5),d5
  1205.         bra    plr_newper
  1206. ;    **************************************** Effect 00 ******
  1207. fx_00:        tst.b    d4    ;both fxqualifiers are 0s: no arpeggio
  1208.         beq.w    fx_xx
  1209.         move.l    d3,d0
  1210.         divu    #3,d0
  1211.         swap    d0
  1212.         tst.w    d0
  1213.         bne.s    fx_arp12
  1214.         and.b    #$0f,d4
  1215.         add.b    (a5),d4
  1216.         bra.s    fx_doarp
  1217. fx_arp12:    subq.b    #1,d0
  1218.         bne.s    fx_arp2
  1219.         lsr.b    #4,d4
  1220.         add.b    (a5),d4
  1221.         bra.s    fx_doarp
  1222. fx_arp2:    move.b    (a5),d4
  1223. fx_doarp:    subq.b    #1,d4        ;-1 to make it 0 - 127
  1224.         add.b    msng_playtransp(a4),d4    ;add play transpose
  1225.         add.b    trk_stransp(a5),d4    ;add instrument transpose
  1226.         add.b    d4,d4
  1227.         movea.l    trk_periodtbl(a5),a1
  1228.         move.w    0(a1,d4.w),d5
  1229.         bra.w    plr_newper
  1230. ;    **************************************** Effect 04 ******
  1231. fx_14        move.b    #6,trk_vibshift(a5)
  1232.         bra.s    vib_cont
  1233. fx_04        move.b    #5,trk_vibshift(a5)
  1234. vib_cont    tst.b    d3
  1235.         bne.s    nonvib
  1236.         move.b    d4,d1
  1237.         beq.s    nonvib
  1238.         and.w    #$0f,d1
  1239.         beq.s    plr_chgvibspd
  1240.         move.w    d1,trk_vibrsz(a5)
  1241. plr_chgvibspd:    and.b    #$f0,d4
  1242.         beq.s    nonvib
  1243.         lsr.b    #3,d4
  1244.         and.b    #$3e,d4
  1245.         move.b    d4,trk_vibrspd(a5)
  1246. nonvib:        move.b    trk_vibroffs(a5),d0
  1247.         lsr.b    #2,d0
  1248.         and.w    #$1f,d0
  1249.         moveq    #0,d1
  1250.         move.b    sinetable(pc,d0.w),d5
  1251.         ext.w    d5
  1252.         muls    trk_vibrsz(a5),d5
  1253.         move.b    trk_vibshift(a5),d1
  1254.         asr.w    d1,d5
  1255.         add.w    trk_prevper(a5),d5
  1256.         move.b    trk_vibrspd(a5),d0
  1257.         add.b    d0,trk_vibroffs(a5)
  1258.         bra.w    plr_newper
  1259. sinetable:    dc.b    0,25,49,71,90,106,117,125,127,125,117,106,90,71,49
  1260.         dc.b    25,0,-25,-49,-71,-90,-106,-117,-125,-127,-125,-117
  1261.         dc.b    -106,-90,-71,-49,-25,0
  1262. ;    **************************************** Effect 06 ******
  1263. fx_06:        tst.b    d3
  1264.         bne.s    fx_06nocnt0
  1265.         btst    #5,msng_flags(a4)
  1266.         bne    newvals
  1267. fx_06nocnt0    bsr.s    plr_volslide        ;Volume slide
  1268.         bra.s    nonvib            ;+ Vibrato
  1269. ;    **************************************** Effect 07 ******
  1270. fx_07        tst.b    d3
  1271.         bne.s    nontre
  1272.         move.b    d4,d1
  1273.         beq.s    nontre
  1274.         and.w    #$0f,d1
  1275.         beq.s    plr_chgtrespd
  1276.         move.w    d1,trk_tremsz(a5)
  1277. plr_chgtrespd    and.b    #$f0,d4
  1278.         beq.s    nonvib
  1279.         lsr.b    #2,d4
  1280.         and.b    #$3e,d4
  1281.         move.b    d4,trk_tremspd(a5)
  1282. nontre        move.b    trk_tremoffs(a5),d0
  1283.         lsr.b    #3,d0
  1284.         and.w    #$1f,d0
  1285.         moveq    #0,d1
  1286.         move.b    sinetable(pc,d0.w),d5
  1287.         ext.w    d5
  1288.         muls    trk_tremsz(a5),d5
  1289.         asr.w    #7,d5
  1290.         move.b    trk_tremspd(a5),d0
  1291.         add.b    d0,trk_tremoffs(a5)
  1292.         move.b    trk_prevvol(a5),d1
  1293.         add.b    d5,d1
  1294.         bpl.s    tre_pos
  1295.         moveq    #0,d1
  1296. tre_pos        cmp.b    #64,d1
  1297.         ble.s    tre_no2hi
  1298.         moveq    #64,d1
  1299. tre_no2hi    move.b    d1,trk_tempvol(a5)
  1300.         bra.w    newvals
  1301. ;    **************************************** Effect 0D/0A ***
  1302. fx_0a:
  1303. fx_0d:        tst.b    d3
  1304.         bne.s    fx_0dnocnt0
  1305.         btst    #5,msng_flags(a4)
  1306.         bne    newvals
  1307. fx_0dnocnt0    bsr.s    plr_volslide
  1308.         bra    newvals
  1309. ;    ********* VOLUME SLIDE FUNCTION *************************
  1310. plr_volslide    move.b    d4,d0
  1311.         moveq    #0,d1
  1312.         move.b    trk_prevvol(a5),d1 ;move previous vol to d1
  1313.         and.b    #$f0,d0
  1314.         bne.s    crescendo
  1315.         sub.b    d4,d1    ;sub from prev. vol
  1316. voltest0    bpl.s    novolover64
  1317.         moveq    #0,d1    ;volumes under zero not accepted!!!
  1318.         bra.s    novolover64
  1319. crescendo:    lsr.b    #4,d0
  1320.         add.b    d0,d1
  1321. voltest        cmp.b    #64,d1
  1322.         ble.s    novolover64
  1323.         moveq    #64,d1
  1324. novolover64    move.b    d1,trk_prevvol(a5)
  1325.         movea.l    trk_audioaddr(a5),a0
  1326.         movea.l    ac_vol(a0),a0
  1327.         move.b    d1,(a0)
  1328.         rts
  1329. ;    **************************************** Effect 1A ******
  1330. fx_1a        tst.b    d3
  1331.         bne    fx_xx
  1332.         move.b    trk_prevvol(a5),d1
  1333.         add.b    d4,d1
  1334.         bsr.s    voltest
  1335.         bra    newvals
  1336. ;    **************************************** Effect 1B ******
  1337. fx_1b        tst.b    d3
  1338.         bne    fx_xx
  1339.         move.b    trk_prevvol(a5),d1
  1340.         sub.b    d4,d1
  1341.         bsr.s    voltest0
  1342.         bra    newvals
  1343. ;    **************************************** Effect 05 ******
  1344. fx_05:        tst.b    d3
  1345.         bne.s    fx_05nocnt0
  1346.         btst    #5,msng_flags(a4)
  1347.         bne    newvals
  1348. fx_05nocnt0    bsr.s    plr_volslide        ;Volume slide
  1349.         bra.s    fx_03nocnt0
  1350. ;    **************************************** Effect 03 ******
  1351. fx_03:        tst.b    d3
  1352.         bne.s    fx_03nocnt0
  1353.         btst    #5,msng_flags(a4)
  1354.         bne    newvals
  1355. fx_03nocnt0    move.w    trk_porttrgper(a5),d0    ;d0 = target period
  1356.         beq.w    newvals    ;no target period specified
  1357.         move.w    trk_prevper(a5),d1    ;d1 = curr. period
  1358.         move.b    trk_prevportspd(a5),d4    ;get prev. speed
  1359.         cmp.w    d0,d1
  1360.         bhi.s    subper    ;curr. period > target period
  1361.         add.w    d4,d1    ;add the period
  1362.         cmp.w    d0,d1
  1363.         bge.s    targreached
  1364.         bra.s    targnreach
  1365. subper:        sub.w    d4,d1    ;subtract
  1366.         cmp.w    d0,d1    ;compare current period to target period
  1367.         bgt.s    targnreach
  1368. targreached:    move.w    trk_porttrgper(a5),d1 ;eventually push target period
  1369.         clr.w    trk_porttrgper(a5) ;now we can forget everything
  1370. targnreach:    move.w    d1,trk_prevper(a5)
  1371.         move.w    d1,d5
  1372.         bra.s    plr_newper
  1373. ;    **************************************** Effect 13 ******
  1374. fx_13:        move.w    trk_prevper(a5),d5 ;this is very simple: get the old period
  1375.         cmp.b    #3,d3        ;and..
  1376.         bge.s    plr_newper    ;if counter < 3
  1377.         sub.w    d4,d5    ;subtract effect qualifier
  1378.         bra.s    plr_newper
  1379. ;    **************************************** Effect 1E ******
  1380. fx_1e        tst.w    blkdelay-DB(a6)
  1381.         bne.s    fx_xx
  1382.         addq.w    #1,d4
  1383.         move.w    d4,blkdelay-DB(a6)
  1384.         bra.s    fx_xx
  1385. ;    **************************************** Effect 18 ******
  1386. fx_18        cmp.b    d4,d3
  1387.         bne    fx_xx
  1388.         clr.w    trk_prevper(a5)
  1389.         bra.s    endl
  1390. ;    **************************************** Effect 1F ******
  1391. fx_1f        move.b    d4,d1
  1392.         lsr.b    #4,d4        ;note delay
  1393.         beq.s    nonotedelay
  1394.         cmp.b    d4,d3        ;compare to counter
  1395.         blt.s    fx_xx        ;tick not reached
  1396.         bne.s    nonotedelay
  1397.         bsr    playfxnote    ;trigger note
  1398. nonotedelay    and.w    #$0f,d1        ;retrig?
  1399.         beq.s    fx_xx
  1400.         moveq    #0,d0
  1401.         move.b    d3,d0
  1402.         divu    d1,d0
  1403.         swap    d0        ;get modulo of counter/tick
  1404.         tst.w    d0
  1405.         bne.s    fx_xx
  1406.         bsr.s    playfxnote    ;retrigger
  1407.         bra.s    fx_xx
  1408. ;    **************************************** Effect 0F ******
  1409. fx_0f:        bsr.s    cmd_F
  1410. ;    *********************************************************
  1411. fx_xx:
  1412. newvals:    move.w    trk_prevper(a5),d5
  1413. plr_newper
  1414. plr_tmpper    movea.l    trk_audioaddr(a5),a1    ;get channel address
  1415.         move.w    d5,ac_per(a1)        ;push period
  1416. endl:        addq.b    #1,d7    ;increment channel number
  1417.         cmp.w    numtracks-DB(a6),d7    ;all channels done???
  1418.         blt.w    plr_loop1    ;not yet!!!
  1419.  
  1420. plr_exit8    movem.l    (sp)+,d2-d7/a2-a5
  1421.         moveq    #1,d0
  1422.         rts
  1423.  
  1424. cmd_F        cmp.b    #$f1,d4
  1425.         bne.s    no0ff1
  1426.         cmp.b    #3,d3
  1427.         beq.s    playfxnote
  1428.         rts
  1429. no0ff1:        cmp.b    #$f2,d4
  1430.         bne.s    no0ff2
  1431.         cmp.b    #3,d3
  1432.         beq.s    playfxnote
  1433.         rts
  1434. no0ff2:        cmp.b    #$f3,d4
  1435.         bne.s    no0ff3
  1436.         move.b    d3,d0
  1437.         and.b    #2+4,d0        ;is 2 or 4
  1438.         beq.s    cF_rts
  1439. playfxnote:    moveq    #0,d1
  1440.         move.b    (a5),d1        ;get note # of previous note
  1441.         beq.s    cF_rts
  1442.         move.b    trk_noteoffcnt(a5),d0    ;get hold counter
  1443.         bmi.s    pfxn_nohold        ;no hold, or hold over
  1444.         add.b    d3,d0            ;increase by counter val
  1445.         bra.s    pfxn_hold
  1446. pfxn_nohold    move.b    trk_inithold(a5),d0    ;get initial hold
  1447.         bne.s    pfxn_hold
  1448.         st    d0
  1449. pfxn_hold    move.b    d0,trk_noteoffcnt(a5)
  1450.         move.l    d3,-(sp)
  1451.         moveq    #0,d3
  1452.         move.b    trk_previnstr(a5),d3    ;and prev. sample #
  1453.         move.l    a3,-(sp)
  1454.         movea.l    trk_previnstra(a5),a3
  1455.         bsr    _PlayNote8
  1456.         movea.l    (sp)+,a3
  1457.         move.l    (sp)+,d3
  1458.         rts
  1459. no0ff3:        cmp.b    #$f8,d4        ;f8 = filter off
  1460.         beq.s    plr_filteroff
  1461.         cmp.b    #$f9,d4        ;f9 = filter on
  1462.         bne.s    cF_rts
  1463.         bclr    #1,$bfe001
  1464.         rts
  1465. plr_filteroff:    bset    #1,$bfe001
  1466. cF_rts        rts
  1467.  
  1468. _SetTempo:    move.l    _module8-DB(a6),d1
  1469.         beq.s    ST_x
  1470.         movea.l    d1,a0
  1471.         movea.l    mmd_songinfo(a0),a0
  1472.         move.w    d0,msng_deftempo(a0)
  1473.         tst.w    d0
  1474.         ble.s    ST_maxszcnt
  1475.         cmp.w    #9,d0
  1476.         bls.s    ST_nodef8tempo
  1477. ST_maxszcnt    moveq    #10,d0
  1478. ST_nodef8tempo    add.b    #9,d0
  1479.         move.b    d0,currchszcnt-DB+1(a6)
  1480.         lea    eightchsizes-10-DB(a6),a0
  1481.         move.b    0(a0,d0.w),d0    ;get buffersize / 2
  1482.         move.w    d0,currchsize2-DB(a6)
  1483.         asl.w    #3,d0        ;get buffersize * 4
  1484.         move.w    d0,currchsize-DB(a6)
  1485. ST_x        rts
  1486.  
  1487. _Rem8chan:    move.l    a6,-(sp)
  1488.         lea    DB,a6
  1489.         move.b    eightrkon-DB(a6),d0
  1490.         beq.s    no8init
  1491.         clr.b    eightrkon-DB(a6)
  1492.         move.w    #1<<7,$dff09a
  1493.         moveq    #7,d0
  1494.         move.l    prevaud-DB(a6),d0
  1495.         beq.s    no8init
  1496.         move.l    d0,a1
  1497.         move.l    4,a6
  1498.         jsr    -$a2(a6)
  1499. no8init        move.l    (sp)+,a6
  1500.         rts
  1501.  
  1502. _End8Play:    tst.b    play8
  1503.         beq.s    noend8play
  1504.         move.w    #1<<7,$dff09a
  1505.         move.w    #$F,$dff096
  1506.         clr.b    play8
  1507. noend8play    rts
  1508.  
  1509. ; *************************************************************************
  1510. ; *************************************************************************
  1511. ; ***********          P U B L I C   F U N C T I O N S          ***********
  1512. ; *************************************************************************
  1513. ; *************************************************************************
  1514.  
  1515.         xdef    _PlayModule8
  1516.         xdef    _InitPlayer8,_RemPlayer8,_StopPlayer8
  1517.         xdef    _ContModule8
  1518.  
  1519. ; *************************************************************************
  1520. ; InitModule8(a0 = module) -- extract expansion data etc.. from the module
  1521. ; *************************************************************************
  1522.  
  1523. _InitModule8:    movem.l    a2-a3/d2,-(sp)
  1524.         move.l    a0,d0
  1525.         beq.s    IM_exit            ;0 => xit
  1526.         lea    holdvals-DB(a6),a2
  1527.         move.l    mmd_expdata(a0),d0    ;expdata...
  1528.         beq.s    IM_clrhlddec        ;none here
  1529.         move.l    d0,a1
  1530.         move.l    4(a1),d0        ;exp_smp
  1531.         beq.s    IM_clrhlddec    ;again.. nothing
  1532.         move.l    d0,a0        ;InstrExt...
  1533.         move.w    8(a1),d2    ;# of entries
  1534.         beq.s    IM_clrhlddec
  1535.         subq.w    #1,d2        ;- 1 (for dbf)
  1536.         move.w    10(a1),d0    ;entry size
  1537. IM_loop1    cmp.w    #3,d0
  1538.         ble.s    IM_noftune
  1539.         move.b    3(a0),63(a2)
  1540. IM_noftune    move.b    (a0),(a2)+    ;InstrExt.hold -> holdvals
  1541.         adda.w    d0,a0        ;ptr to next InstrExt
  1542.         dbf    d2,IM_loop1
  1543.         bra.s    IM_exit
  1544. IM_clrhlddec    moveq    #125,d0        ;no InstrExt => clear holdvals/decays
  1545. IM_loop2    clr.b    (a2)+
  1546.         dbf    d0,IM_loop2
  1547. IM_exit        movem.l    (sp)+,a2-a3/d2
  1548.         rts
  1549.  
  1550.  
  1551. ; *************************************************************************
  1552. ; ContModule8(a0 = module) -- continue playing
  1553. ; *************************************************************************
  1554. _ContModule8    bsr.w    _End8Play
  1555.         moveq    #0,d0
  1556.         bra.s    contpoint8
  1557. ; *************************************************************************
  1558. ; PlayModule8(a0 = module)  -- init and play a module
  1559. ; *************************************************************************
  1560. _PlayModule8:    st    d0
  1561. contpoint8    move.l    a6,-(sp)
  1562.         lea    DB,a6
  1563.         movem.l    a0/d0,-(sp)
  1564.         bsr    _InitModule8
  1565.         movem.l    (sp)+,a0/d0
  1566.     IFNE    AUDDEV
  1567.         tst.b    audiodevopen-DB(a6)
  1568.         beq.s    PM_end        ;resource allocation failure
  1569.     ENDC
  1570.         move.l    a0,d1
  1571.         beq.s    PM_end        ;module failure
  1572.         bsr.w    _End8Play
  1573.         clr.l    _module8-DB(a6)
  1574.         move.w    _modnum8,d1
  1575.         beq.s    PM_modfound
  1576. PM_nextmod    tst.l    mmd_expdata(a0)
  1577.         beq.s    PM_modfound
  1578.         move.l    mmd_expdata(a0),a1
  1579.         tst.l    (a1)
  1580.         beq.s    PM_modfound        ;no more modules here!
  1581.         move.l    (a1),a0
  1582.         subq.w    #1,d1
  1583.         bgt.s    PM_nextmod
  1584. PM_modfound    movea.l    mmd_songinfo(a0),a1        ;song
  1585.         move.b    msng_tempo2(a1),mmd_counter(a0)    ;init counter
  1586.         btst    #0,msng_flags(a1)
  1587.         bne.s    PM_filon
  1588.         bset    #1,$bfe001
  1589.         bra.s    PM_filset
  1590. PM_filon    bclr    #1,$bfe001
  1591. PM_filset    tst.b    d0
  1592.         beq.s    PM_noclr
  1593.         clr.l    mmd_pline(a0)
  1594. PM_noclr    move.w    mmd_pseqnum(a0),d1
  1595.         add.w    #msng_playseq,d1
  1596.         move.b    0(a1,d1.w),d1
  1597.         move.b    d1,mmd_pblock+1(a0)
  1598.         move.w    #-1,mmd_pstate(a0)
  1599.         move.l    a0,_module8-DB(a6)
  1600.         move.l    mmd_expdata(a0),d0
  1601.         beq.s    PM_start
  1602.         movea.l    d0,a0
  1603.         lea    36(a0),a0    ;track split mask
  1604.         bsr.s    _SetChMode
  1605. PM_start    bsr.s    _Start8Play
  1606. PM_end        move.l    (sp)+,a6
  1607.         rts
  1608.  
  1609. _SetChMode    ;a0 = address of 4 UBYTEs
  1610.         movem.l    a2/d2,-(sp)
  1611.         lea    trksplit-DB(a6),a2
  1612.         lea    t038+trk_split-DB(a6),a1
  1613.         moveq    #3,d0
  1614.         moveq    #0,d1
  1615. scm_loop    lsr.b    #1,d1
  1616.         move.b    (a0)+,d2
  1617.         beq.s    scm_split
  1618.         moveq    #0,d2
  1619.         bra.s    scm_nosplit
  1620. scm_split    or.b    #8,d1
  1621.         st    d2
  1622. scm_nosplit    move.b    d2,(a1)
  1623.         move.b    d2,4*T03SZ(a1)
  1624.         lea    T03SZ(a1),a1
  1625.         move.b    d2,(a2)+
  1626.         dbf    d0,scm_loop
  1627.         move.w    d1,chdmamask-DB(a6)
  1628.         movem.l    (sp)+,a2/d2
  1629. rts:        rts
  1630.  
  1631. _Start8Play:    ;d0 = pstate
  1632.         lea    _audiobuff,a0
  1633.         move.w    #1600-1,d1
  1634. clrbuffloop:    clr.w    (a0)+        ;clear track buffers
  1635.         dbf    d1,clrbuffloop
  1636.         move.l    _module8-DB(a6),d0
  1637.         beq.s    rts
  1638.         move.l    d0,a0
  1639.         movea.l    mmd_songinfo(a0),a0
  1640.         move.w    msng_deftempo(a0),d0    ;get deftempo
  1641.         bsr.w    _SetTempo
  1642.         lea    $dff000,a0
  1643.         move.w    currchsize2-DB(a6),d0
  1644.         move.w    d0,$a4(a0)    ;set audio buffer sizes
  1645.         move.w    d0,$b4(a0)    ;according to tempo selection
  1646.         move.w    d0,$c4(a0)
  1647.         move.w    d0,$d4(a0)
  1648.         move.w    #227,d1
  1649.         move.w    d1,$a6(a0)
  1650.         move.w    d1,$b6(a0)
  1651.         move.w    d1,$c6(a0)
  1652.         move.w    d1,$d6(a0)
  1653.         move.l    #_audiobuff,$a0(a0)
  1654.         move.l    #_audiobuff+800,$b0(a0)
  1655.         move.l    #_audiobuff+1600,$c0(a0)
  1656.         move.l    #_audiobuff+2400,$d0(a0)
  1657.         moveq    #64,d1
  1658.         move.w    d1,$a8(a0)
  1659.         move.w    d1,$b8(a0)
  1660.         move.w    d1,$c8(a0)
  1661.         move.w    d1,$d8(a0)
  1662.         clr.b    whichbuff-DB(a6)
  1663.         movea.l    4,a1
  1664.         move.w    #$4000,$9a(a0)
  1665.         addq.b    #1,$126(a1)
  1666.         lea    track0hw-DB(a6),a1
  1667.         moveq    #7,d1
  1668. clrtrkloop    clr.l    (a1)
  1669.         clr.w    ac_per(a1)
  1670.         adda.w    #SIZE4TRKHW/4,a1
  1671.         dbf    d1,clrtrkloop
  1672.         move.w    #$F,$dff096    ;audio DMA off
  1673.         bsr.w    _Wait1line    ;wait until all stopped
  1674.         st    play8-DB(a6)
  1675.         move.w    #$8080,$9a(a0)
  1676.         move.w    chdmamask-DB(a6),d1
  1677.         bset    #15,d1
  1678.         move.w    d1,$96(a0)
  1679.         movea.l    4,a1
  1680.         subq.b    #1,$126(a1)
  1681.         bge.s    x8play
  1682.         move.w    #$c000,$9a(a0)
  1683. x8play        rts
  1684. ; *************************************************************************
  1685. ; InitPlayer8() -- allocate interrupt, audio, serial port etc...
  1686. ; *************************************************************************
  1687. _InitPlayer8:    bsr.s    _AudioInit
  1688.         tst.l    d0
  1689.         bne.s    IP_error
  1690.         rts
  1691. IP_error    bsr.s    _RemPlayer8
  1692.         moveq    #-1,d0
  1693.         rts
  1694. ; *************************************************************************
  1695. ; StopPlayer8() -- stop music
  1696. ; *************************************************************************
  1697. _StopPlayer8:    move.l    _module8,d0
  1698.         beq.s    SP_nomod
  1699.         movea.l    d0,a0
  1700.         clr.w    mmd_pstate(a0)
  1701.         clr.l    _module8
  1702. SP_nomod    bra.w    _End8Play
  1703.  
  1704. ; *************************************************************************
  1705. ; RemPlayer8() -- free interrupt, audio, serial port etc..
  1706. ; *************************************************************************
  1707. _RemPlayer8:    bsr.s    _StopPlayer8
  1708. ;        vvvvvvvvvvvvvvvv  to _AudioRem
  1709. ; *************************************************************************
  1710. _AudioRem:    movem.l    a5-a6,-(sp)
  1711.         lea    DB,a5
  1712.         bsr.w    _Rem8chan
  1713.     IFNE    AUDDEV
  1714.         movea.l    4,a6
  1715.         tst.b    audiodevopen-DB(a5)
  1716.         beq.s    rem2
  1717.         clr.b    audiodevopen-DB(a5)
  1718.         move.w    #$000f,$dff096    ;stop audio DMA
  1719. ;    +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ close audio.device
  1720.         lea    allocreq-DB(a5),a1
  1721.         jsr    -$1c2(a6)    ;CloseDevice()
  1722. rem2:        moveq    #0,d0
  1723.         move.b    sigbitnum-DB(a5),d0
  1724.         bmi.s    rem3
  1725. ;    +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ free signal bit
  1726.         jsr    -$150(a6)    ;FreeSignal()
  1727.         st    sigbitnum-DB(a5)
  1728.     ENDC
  1729. rem3:        movem.l    (sp)+,a5-a6
  1730.         rts
  1731.  
  1732. _AudioInit:    movem.l    a4/a6/d2-d3,-(sp)
  1733.         lea    DB,a4
  1734.         movea.l    4,a6
  1735.     IFNE    AUDDEV
  1736.         moveq    #0,d2
  1737. ;    +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ alloc signal bit
  1738.         moveq    #1,d2
  1739.         moveq    #-1,d0
  1740.         jsr    -$14a(a6)    ;AllocSignal()
  1741.         tst.b    d0
  1742.         bmi.w    initerr
  1743.         move.b    d0,sigbitnum-DB(a4)
  1744. ;    +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ prepare IORequest
  1745.         lea    allocport-DB(a4),a1
  1746.         move.b    d0,15(a1)    ;set mp_SigBit
  1747.         move.l    a1,-(sp)
  1748.         suba.l    a1,a1
  1749.         jsr    -$126(a6)    ;FindTask(0)
  1750.         move.l    (sp)+,a1
  1751.         move.l    d0,16(a1)    ;set mp_SigTask
  1752.         lea    reqlist-DB(a4),a0
  1753.         move.l    a0,(a0)        ;NEWLIST begins...
  1754.         addq.l    #4,(a0)
  1755.         clr.l    4(a0)
  1756.         move.l    a0,8(a0)    ;NEWLIST ends...
  1757. ;    +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ open audio.device
  1758.         moveq    #2,d2
  1759.         lea    allocreq-DB(a4),a1
  1760.         lea    audiodevname-DB(a4),a0
  1761.         moveq    #0,d0
  1762.         moveq    #0,d1
  1763.         jsr    -$1bc(a6)    ;OpenDevice()
  1764.         tst.b    d0
  1765.         bne.w    initerr
  1766.         st.b    audiodevopen-DB(a4)
  1767.     ENDC
  1768.         move.w    #1<<7,$dff09a    ;Init 8 channel stuff
  1769.         moveq    #7,d0        ;Audio channel 0 interrupt
  1770.         lea    audiointerrupt-DB(a4),a1
  1771.         jsr    -$a2(a6)    ;SetIntVector()
  1772.         move.l    d0,prevaud-DB(a4)
  1773.         st    eightrkon-DB(a4)
  1774.         moveq    #0,d0
  1775. initret:    movem.l    (sp)+,a4/a6/d2-d3
  1776.         rts
  1777. initerr:    move.l    d2,d0
  1778.         bra.s    initret
  1779.  
  1780.         DATA
  1781. DB:        ;Data base pointer
  1782.     IFNE    AUDDEV
  1783. sigbitnum    dc.b    -1
  1784. audiodevopen    dc.b    0
  1785. allocm        dc.b    $F,0
  1786.     ENDC
  1787. chdmamask    dc.w    0
  1788. trksplit    dc.b    0,0,0,0
  1789.         even
  1790.     IFNE    AUDDEV
  1791. allocport    dc.l    0,0    ;succ, pred
  1792.         dc.b    4,0    ;NT_MSGPORT
  1793.         dc.l    0    ;name
  1794.         dc.b    0,0    ;flags = PA_SIGNAL
  1795.         dc.l    0    ;task
  1796. reqlist        dc.l    0,0,0    ;list head, tail and tailpred
  1797.         dc.b    5,0
  1798. allocreq    dc.l    0,0
  1799.         dc.b    0,127    ;NT_UNKNOWN, use maximum priority (127)
  1800.         dc.l    0,allocport    ;name, replyport
  1801.         dc.w    68        ;length
  1802.         dc.l    0    ;io_Device
  1803.         dc.l    0    ;io_Unit
  1804.         dc.w    0    ;io_Command
  1805.         dc.b    0,0    ;io_Flags, io_Error
  1806.         dc.w    0    ;ioa_AllocKey
  1807.         dc.l    allocm    ;ioa_Data
  1808.         dc.l    1    ;ioa_Length
  1809.         dc.w    0,0,0    ;ioa_Period, Volume, Cycles
  1810.         dc.w    0,0,0,0,0,0,0,0,0,0    ;ioa_WriteMsg
  1811. audiodevname    dc.b    'audio.device',0
  1812.     ENDC
  1813.         even
  1814.  
  1815. zerodata    dc.w    0
  1816. whichbuff    dc.w    0
  1817.  
  1818. track0hw    dc.l    0,0,$dff0a9,0,0
  1819.         dc.w    $0001,$df,$f0a0
  1820. track1hw    dc.l    0,0,$dff0b9,0,0
  1821.         dc.w    $0002,$df,$f0b0
  1822. track2hw    dc.l    0,0,$dff0c9,0,0
  1823.         dc.w    $0004,$df,$f0c0
  1824. track3hw    dc.l    0,0,$dff0d9,0,0
  1825.         dc.w    $0008,$df,$f0d0
  1826. track4hw    dc.l    0,0,$dff0a9,0,0
  1827.         dc.w    0,0,0
  1828. track5hw    dc.l    0,0,$dff0b9,0,0
  1829.         dc.w    0,0,0
  1830. track6hw    dc.l    0,0,$dff0c9,0,0
  1831.         dc.w    0,0,0
  1832. track7hw    dc.l    0,0,$dff0d9,0,0
  1833.         dc.w    0,0,0
  1834. SIZE4TRKHW    equ    4*$1A
  1835.  
  1836. audintname    dc.b    'OctaMED AudioInterrupt',0
  1837.         even
  1838. audiointerrupt    dc.w    0,0,0,0,0
  1839.         dc.l    audintname,_audiobuff,_IntHandler8
  1840. prevaud        dc.l    0
  1841. play8        dc.b    0
  1842. eightrkon    dc.b    0
  1843.  
  1844. t038:        ds.b    22
  1845.         dc.l    track0hw
  1846.         ds.b    71
  1847.         dc.b    $ff
  1848.         ds.b    22
  1849.         dc.l    track1hw
  1850.         ds.b    71
  1851.         dc.b    $ff
  1852.         ds.b    22
  1853. t238        dc.l    track2hw
  1854.         ds.b    71
  1855.         dc.b    $ff
  1856.         ds.b    22
  1857.         dc.l    track3hw
  1858.         ds.b    71
  1859.         dc.b    $ff
  1860. t4158        ds.b    22
  1861.         dc.l    track4hw
  1862.         ds.b    71
  1863.         dc.b    $ff
  1864.         ds.b    22
  1865.         dc.l    track5hw
  1866.         ds.b    71
  1867.         dc.b    $ff
  1868.         ds.b    22
  1869. t6158        dc.l    track6hw
  1870.         ds.b    71
  1871.         dc.b    $ff
  1872.         ds.b    22
  1873.         dc.l    track7hw
  1874.         ds.b    71
  1875.         dc.b    $ff
  1876.         
  1877. trackdata8    dc.l    t038,t038+T03SZ,t038+2*T03SZ,t038+3*T03SZ
  1878.         dc.l    t4158,t4158+T03SZ,t4158+2*T03SZ,t4158+3*T03SZ
  1879.  
  1880. blkdelay    dc.w    0    ;block delay (PT PatternDelay)
  1881.  
  1882. eightchsizes    dc.b    110,120,130,140,150,160,170,180,190,200
  1883. currchsize    dc.w    0    ;<< 3
  1884. currchsize2    dc.w    0
  1885. currchszcnt    dc.w    0
  1886.  
  1887. nextblock    dc.b    0 ;\ DON'T SEPARATE
  1888. nxtnoclrln    dc.b    0 :/
  1889. numtracks    dc.w    0
  1890. numlines    dc.w    0
  1891. nextblockline    dc.w    0
  1892. rptline        dc.w    0
  1893. rptcounter    dc.w    0
  1894. _module8    dc.l    0
  1895.  
  1896.         EVEN
  1897. holdvals    ds.b    63
  1898.         ds.b    63    ;finetune
  1899.  
  1900. per0    dc.w    856,808,762,720,678,640,604,570,538,508,480,453
  1901.     dc.w    428,404,381,360,339,320,302,285,269,254,240,226
  1902.     dc.w    214,202,190,180,170,160,151,143,135,127,120,113
  1903.     dc.w    214,202,190,180,170,160,151,143,135,127,120,113
  1904.     dc.w    214,202,190,180,170,160,151,143,135,127,120,113
  1905.     dc.w    214,202,190,180,170,160,151,143,135,127,120,113
  1906. per1    dc.w    850,802,757,715,674,637,601,567,535,505,477,450
  1907.     dc.w    425,401,379,357,337,318,300,284,268,253,239,225
  1908.     dc.w    213,201,189,179,169,159,150,142,134,126,119,113
  1909.     dc.w    213,201,189,179,169,159,150,142,134,126,119,113
  1910.     dc.w    213,201,189,179,169,159,150,142,134,126,119,113
  1911.     dc.w    213,201,189,179,169,159,150,142,134,126,119,113
  1912. per2    dc.w    844,796,752,709,670,632,597,563,532,502,474,447
  1913.     dc.w    422,398,376,355,335,316,298,282,266,251,237,224
  1914.     dc.w    211,199,188,177,167,158,149,141,133,125,118,112
  1915.     dc.w    211,199,188,177,167,158,149,141,133,125,118,112
  1916.     dc.w    211,199,188,177,167,158,149,141,133,125,118,112
  1917.     dc.w    211,199,188,177,167,158,149,141,133,125,118,112
  1918. per3    dc.w    838,791,746,704,665,628,592,559,528,498,470,444
  1919.     dc.w    419,395,373,352,332,314,296,280,264,249,235,222
  1920.     dc.w    209,198,187,176,166,157,148,140,132,125,118,111
  1921.     dc.w    209,198,187,176,166,157,148,140,132,125,118,111
  1922.     dc.w    209,198,187,176,166,157,148,140,132,125,118,111
  1923.     dc.w    209,198,187,176,166,157,148,140,132,125,118,111
  1924. per4    dc.w    832,785,741,699,660,623,588,555,524,495,467,441
  1925.     dc.w    416,392,370,350,330,312,294,278,262,247,233,220
  1926.     dc.w    208,196,185,175,165,156,147,139,131,124,117,110
  1927.     dc.w    208,196,185,175,165,156,147,139,131,124,117,110
  1928.     dc.w    208,196,185,175,165,156,147,139,131,124,117,110
  1929.     dc.w    208,196,185,175,165,156,147,139,131,124,117,110
  1930. per5    dc.w    826,779,736,694,655,619,584,551,520,491,463,437
  1931.     dc.w    413,390,368,347,328,309,292,276,260,245,232,219
  1932.     dc.w    206,195,184,174,164,155,146,138,130,123,116,109
  1933.     dc.w    206,195,184,174,164,155,146,138,130,123,116,109
  1934.     dc.w    206,195,184,174,164,155,146,138,130,123,116,109
  1935.     dc.w    206,195,184,174,164,155,146,138,130,123,116,109
  1936. per6    dc.w    820,774,730,689,651,614,580,547,516,487,460,434
  1937.     dc.w    410,387,365,345,325,307,290,274,258,244,230,217
  1938.     dc.w    205,193,183,172,163,154,145,137,129,122,115,109
  1939.     dc.w    205,193,183,172,163,154,145,137,129,122,115,109
  1940.     dc.w    205,193,183,172,163,154,145,137,129,122,115,109
  1941.     dc.w    205,193,183,172,163,154,145,137,129,122,115,109
  1942. per7    dc.w    814,768,725,684,646,610,575,543,513,484,457,431
  1943.     dc.w    407,384,363,342,323,305,288,272,256,242,228,216
  1944.     dc.w    204,192,181,171,161,152,144,136,128,121,114,108
  1945.     dc.w    204,192,181,171,161,152,144,136,128,121,114,108
  1946.     dc.w    204,192,181,171,161,152,144,136,128,121,114,108
  1947.     dc.w    204,192,181,171,161,152,144,136,128,121,114,108
  1948. per_8    dc.w    907,856,808,762,720,678,640,604,570,538,508,480
  1949.     dc.w    453,428,404,381,360,339,320,302,285,269,254,240
  1950.     dc.w    226,214,202,190,180,170,160,151,143,135,127,120
  1951.     dc.w    226,214,202,190,180,170,160,151,143,135,127,120
  1952.     dc.w    226,214,202,190,180,170,160,151,143,135,127,120
  1953.     dc.w    226,214,202,190,180,170,160,151,143,135,127,120
  1954. per_7    dc.w    900,850,802,757,715,675,636,601,567,535,505,477
  1955.     dc.w    450,425,401,379,357,337,318,300,284,268,253,238
  1956.     dc.w    225,212,200,189,179,169,159,150,142,134,126,119
  1957.     dc.w    225,212,200,189,179,169,159,150,142,134,126,119
  1958.     dc.w    225,212,200,189,179,169,159,150,142,134,126,119
  1959.     dc.w    225,212,200,189,179,169,159,150,142,134,126,119
  1960. per_6    dc.w    894,844,796,752,709,670,632,597,563,532,502,474
  1961.     dc.w    447,422,398,376,355,335,316,298,282,266,251,237
  1962.     dc.w    223,211,199,188,177,167,158,149,141,133,125,118
  1963.     dc.w    223,211,199,188,177,167,158,149,141,133,125,118
  1964.     dc.w    223,211,199,188,177,167,158,149,141,133,125,118
  1965.     dc.w    223,211,199,188,177,167,158,149,141,133,125,118
  1966. per_5    dc.w    887,838,791,746,704,665,628,592,559,528,498,470
  1967.     dc.w    444,419,395,373,352,332,314,296,280,264,249,235
  1968.     dc.w    222,209,198,187,176,166,157,148,140,132,125,118
  1969.     dc.w    222,209,198,187,176,166,157,148,140,132,125,118
  1970.     dc.w    222,209,198,187,176,166,157,148,140,132,125,118
  1971.     dc.w    222,209,198,187,176,166,157,148,140,132,125,118
  1972. per_4    dc.w    881,832,785,741,699,660,623,588,555,524,494,467
  1973.     dc.w    441,416,392,370,350,330,312,294,278,262,247,233
  1974.     dc.w    220,208,196,185,175,165,156,147,139,131,123,117
  1975.     dc.w    220,208,196,185,175,165,156,147,139,131,123,117
  1976.     dc.w    220,208,196,185,175,165,156,147,139,131,123,117
  1977.     dc.w    220,208,196,185,175,165,156,147,139,131,123,117
  1978. per_3    dc.w    875,826,779,736,694,655,619,584,551,520,491,463
  1979.     dc.w    437,413,390,368,347,328,309,292,276,260,245,232
  1980.     dc.w    219,206,195,184,174,164,155,146,138,130,123,116
  1981.     dc.w    219,206,195,184,174,164,155,146,138,130,123,116
  1982.     dc.w    219,206,195,184,174,164,155,146,138,130,123,116
  1983.     dc.w    219,206,195,184,174,164,155,146,138,130,123,116
  1984. per_2    dc.w    868,820,774,730,689,651,614,580,547,516,487,460
  1985.     dc.w    434,410,387,365,345,325,307,290,274,258,244,230
  1986.     dc.w    217,205,193,183,172,163,154,145,137,129,122,115
  1987.     dc.w    217,205,193,183,172,163,154,145,137,129,122,115
  1988.     dc.w    217,205,193,183,172,163,154,145,137,129,122,115
  1989.     dc.w    217,205,193,183,172,163,154,145,137,129,122,115
  1990. per_1    dc.w    862,814,768,725,684,646,610,575,543,513,484,457
  1991.     dc.w    431,407,384,363,342,323,305,288,272,256,242,228
  1992.     dc.w    216,203,192,181,171,161,152,144,136,128,121,114
  1993.     dc.w    216,203,192,181,171,161,152,144,136,128,121,114
  1994.     dc.w    216,203,192,181,171,161,152,144,136,128,121,114
  1995.     dc.w    216,203,192,181,171,161,152,144,136,128,121,114
  1996.  
  1997. _periodtable
  1998.     dc.l    per_8,per_7,per_6,per_5,per_4,per_3,per_2,per_1,per0
  1999.     dc.l    per1,per2,per3,per4,per5,per6,per7
  2000.  
  2001.     IFND    __G2
  2002.         section "datachip",bss,chip ;for A68k
  2003.     ENDC
  2004.     IFD    __G2
  2005.         section "datachip",bss_c ;this is for Devpac 2
  2006.     ENDC
  2007.  
  2008.         XDEF    _modnum8
  2009. _audiobuff:    ds.w    200*8
  2010. _modnum8:    ds.w    1
  2011. _chipzero:    ds.w    1
  2012.  
  2013. ; the track-data structure definition:
  2014. trk_prevnote    EQU    0    ;previous note number
  2015. trk_previnstr    EQU    1    ;previous instrument number
  2016. trk_prevvol    EQU    2    ;previous volume
  2017. trk_prevmidich    EQU    3    ;previous MIDI channel
  2018. trk_cmd        EQU    4    ;command (the 3rd number from right)
  2019. trk_cmdqual    EQU    5    ;command qualifier (infobyte, databyte..)
  2020. trk_prevmidin    EQU    6    ;previous MIDI note
  2021. trk_noteoffcnt    EQU    7    ;note-off counter (hold)
  2022. trk_inithold    EQU    8    ;default hold for this instrument
  2023. trk_initdecay    EQU    9    ;default decay for....
  2024. trk_stransp    EQU    10    ;instrument transpose
  2025. trk_finetune    EQU    11    ;finetune
  2026. trk_soffset    EQU    12    ;new sample offset
  2027. trk_previnstra    EQU    14    ;address of the previous instrument data
  2028. trk_trackvol    EQU    18
  2029. ;    the following data only on tracks 0 - 3
  2030. trk_prevper    EQU    20    ;previous period
  2031. trk_audioaddr    EQU    22    ;hardware audio channel base address
  2032. trk_sampleptr    EQU    26    ;pointer to sample
  2033. trk_samplelen    EQU    30    ;length (>> 1)
  2034. trk_porttrgper    EQU    32    ;portamento (cmd 3) target period
  2035. trk_vibshift    EQU    34    ;vibrato shift for ASR instruction
  2036. trk_vibrspd    EQU    35    ;vibrato speed/size (cmd 4 qualifier)
  2037. trk_vibrsz    EQU    36    ;vibrato size
  2038. trk_synthptr    EQU    38    ;pointer to synthetic/hybrid instrument
  2039. trk_arpgoffs    EQU    42    ;SYNTH: current arpeggio offset
  2040. trk_arpsoffs    EQU    44    ;SYNTH: arpeggio restart offset
  2041. trk_volxcnt    EQU    46    ;SYNTH: volume execute counter
  2042. trk_wfxcnt    EQU    47    ;SYNTH: waveform execute counter
  2043. trk_volcmd    EQU    48    ;SYNTH: volume command pointer
  2044. trk_wfcmd    EQU    50    ;SYNTH: waveform command pointer
  2045. trk_volwait    EQU    52    ;SYNTH: counter for WAI (volume list)
  2046. trk_wfwait    EQU    53    ;SYNTH: counter for WAI (waveform list)
  2047. trk_synthvibspd    EQU    54    ;SYNTH: vibrato speed
  2048. trk_wfchgspd    EQU    56    ;SYNTH: period change
  2049. trk_perchg    EQU    58    ;SYNTH: curr. period change from trk_prevper
  2050. trk_envptr    EQU    60    ;SYNTH: envelope waveform pointer
  2051. trk_synvibdep    EQU    64    ;SYNTH: vibrato depth
  2052. trk_synvibwf    EQU    66       ;SYNTH: vibrato waveform
  2053. trk_synviboffs    EQU    70    ;SYNTH: vibrato pointer
  2054. trk_initvolxspd    EQU    72    ;SYNTH: volume execute speed
  2055. trk_initwfxspd    EQU    73    ;SYNTH: waveform execute speed
  2056. trk_volchgspd    EQU    74    ;SYNTH: volume change
  2057. trk_prevnote2    EQU    75    ;SYNTH: previous note
  2058. trk_synvol    EQU    76    ;SYNTH: current volume
  2059. trk_synthtype    EQU    77    ;>0 = synth, -1 = hybrid, 0 = no synth
  2060. trk_periodtbl    EQU    78    ;pointer to period table
  2061. trk_prevportspd    EQU    82    ;portamento (cmd 3) speed
  2062. trk_decay    EQU    84    ;decay
  2063. trk_fadespd    EQU    85    ;decay speed
  2064. trk_envrestart    EQU    86    ;SYNTH: envelope waveform restart point
  2065. trk_envcount    EQU    90    ;SYNTH: envelope counter
  2066. trk_split    EQU    91    ;0 = this channel not splitted (OctaMED V2)
  2067. trk_vibroffs    EQU    92    ;vibrato table offset \ DON'T SEPARATE
  2068. trk_tremoffs    EQU    93    ;tremolo table offset /
  2069. trk_tremsz    EQU    94    ;tremolo size
  2070. trk_tremspd    EQU    96    ;tremolo speed
  2071. trk_tempvol    EQU    97    ;temporary volume (for tremolo)
  2072.         END
  2073.